<template>
    <div id="app">
        <router-view/>
    </div>
</template>

<script>
  export default {
    name: 'App',
    data() {
       return {
         ws: null
       }
    },
    methods: {
      connect () {
        // this.ws = new WebSocket("ws://qudian.qicp.vip/message");
        this.ws = new WebSocket("ws://124.71.115.126:8089/message");
        this.ws.onopen = () => {
          console.log("open");
        };
        this.ws.onmessage = (evt) => {
          console.log(evt.data)
          this.$store.dispatch('user/setTaskList', JSON.parse(evt.data))
        };
        this.ws.onclose = (evt) => {
          console.log("WebSocketClosed!");
          console.log(evt);
        };
        this.ws.onerror = (evt) => {
          console.log("WebSocketError!");
          // this.reconnect()
        };
      }
    },
    destroyed () {
      if(this.ws) {
        this.ws.close()
      }
    },
    created () {
      this.connect()
    }
  }
</script>

<style>
    html {
        overflow: hidden;
    }
</style>
